import Vue from 'vue'
import VueI18n from 'vue-i18n'
import Cookies from 'js-cookie'
import elementEnLocale from 'element-ui/lib/locale/lang/en' // element-ui lang
import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN'// element-ui lang
import enLocale from './language.en_US'
import zhLocale from './language.zh_CN'

Vue.use(VueI18n)

const messages = {
  en_US: {
    ...enLocale,
    ...elementEnLocale
  },
  zh_CNS: {
    ...zhLocale,
    ...elementZhLocale
  }
}
// const savedLocale = localStorage.getItem('language') || 'en'; // 如果未设置，则默认为 'en'
const i18n = new VueI18n({
  // 设置语言 选项 en_US | zh_CN
  locale: 'zh_CNS'||Cookies.get('language'), // 通过this.$i18n.locale的值实现语言切换
  // 设置文本内容
  messages
})

export default i18n
